
#include <cppunit/TestCase.h>
#include <cppunit/extensions/HelperMacros.h>

#include "types.h"
#include "Buffer.h"


class BufferTest: public CppUnit::TestFixture {
	typedef Buffer<bool,4> TestBufType;
private:
	TestBufType* bitMap1;
	TestBufType* bitMap2;
	TestBufType* bitMap3;
	TestBufType* bitMap4;

public:
    BufferTest() {}

	void setUp() {
		bool p1[] = {1,1,0,1};
		bool p2[] = {1,0,0,0};
		bool p3[] = {1,1,0,1};
		bool p4[] = {1,1,0,1,0};

		bitMap1 = new TestBufType(p1,4);
		bitMap2 = new TestBufType(p2,4);
		bitMap3 = new TestBufType(p3,4);
		bitMap4 = new TestBufType(p4,5);
	}

	void tearDown() {

	}

	void testEquality() {
		CPPUNIT_ASSERT (*bitMap1 == *bitMap3);
		CPPUNIT_ASSERT (*bitMap3 == *bitMap1);
		CPPUNIT_ASSERT (*bitMap2 != *bitMap1);
		CPPUNIT_ASSERT (*bitMap3 != *bitMap4);
	}

	void testBits () {
		CPPUNIT_ASSERT_EQUAL (4, int(bitMap1->size()));
		CPPUNIT_ASSERT_EQUAL (5, int(bitMap4->size()));
//		CPPUNIT_ASSERT (true== *bitMap1);
//		CPPUNIT_ASSERT(true== *(bitMap1+1));
//		CPPUNIT_ASSERT(0, bitMap1.bitAt(2));
//		CPPUNIT_ASSERT(1, bitMap1.bitAt(3));
//
//		bitMap4.setBitAt(1, 1);
//		CPPUNIT_ASSERT_EQUAL (1, bitMap4.bitAt(1));
//
//		bitMap4.setBitAt(1, 0);
//		CPPUNIT_ASSERT_EQUAL (0, bitMap4.bitAt(1));
	}

CPPUNIT_TEST_SUITE( BufferTest );
	CPPUNIT_TEST( testEquality );
CPPUNIT_TEST_SUITE_END();

};
